maxammann
11. Juni, 2019
Quelle: PoC||GTFO 0x03
file --brief "unzipped/pocorgtfo03-encrypt.py"
Python script, ASCII text executable
python2 "unzipped/pocorgtfo03-encrypt.py"
firefox "enc-pocorgtfo03.pdf.png"Ein Exploit nutzt eine Vulnerability um eine bestimmte unerwartete Aktion auszuführen.
alert("XSS")<div><script title="</div>">
<script><div title="</script>">
Aktuelle HTML-Parser sind zu komplex und zu unterschiedlich.
▶ Serverseitige Sanitisation ist nicht ausreichend!
<template>template = document.createElement("template")
template.innerHTML = '<noscript><p title="</noscript>' +
'<img src=x onerror=alert("XSS")>">'div = document.createElement("div")
div.innerHTML = '<noscript><p title="</noscript>' +
'<img src=x onerror=alert("XSS")>">'
<noscript><p title="</noscript><img src=x onerror=alert("XSS")>">
Der DOM Tree ist je nach Kontext unterschiedlich, obwohl der ursprüngliche HTML-Code der gleiche ist!
4.12.2 The noscript element
The noscript element represents nothing if scripting is enabled, and represents its children if scripting is disabled.
Da in einem <template> tag scripting deaktiviert ist, werden unterschiedliche DOM Trees gebaut.
Content-Security-Policy to the rescue
CSP is a strong defense-in-depth mechanism against XSS.
Quelle: https://www.w3.org/TR/CSP3/
Verbietet inlinen von JavaScript und lässt nur bestimmte Quellen zu.
Erlaubt:
<script nonce="nonce-r4nd0m">alert("XSS")</script>
<script nonce="nonce-r4nd0m"
src="https://cdn/lib.js"></script>Hinweis: Erstetzt nicht das beheben von Fehlern!
<?php
if (empty($_POST['hmac']) || empty($_POST['host'])) {
header('HTTP/1.0 400 Bad Request'); exit;
}
$secret = getenv("SECRET");
if (isset($_POST['nonce']))
$secret = hash_hmac('sha256', $_POST['nonce'], $secret);
$hmac = hash_hmac('sha256', $_POST['host'], $secret);
if ($hmac !== $_POST['hmac']) {
header('HTTP/1.0 403 Forbidden'); exit;
}
echo exec("host ".$_POST['host']);
?>Quelle: www.securify.nl/en/blog/SFY20180101/spot-the-bug-challenge-2018-warm-up.html